/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */

package com.pig4cloud.pigx.strategy.entity;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.pig4cloud.pigx.common.customize.utils.serializer.BigDecimalToPlainStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 策略止盈止损-合约
 *
 * @since 2023/2/7 18:21
 */
@Data
@TableName("strategy_stop_order_contract")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "策略止盈止损-合约")
public class StrategyStopOrderContract extends Model<StrategyStopOrderContract> {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "主键")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /**
     * 外部平台id
     */
    @ApiModelProperty(value = "外部平台id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long externalId;

    /**
     * 平台id
     */
    @ApiModelProperty(value = "平台id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long platformId;

    /**
     * 任务id
     */
    @ApiModelProperty(value = "任务id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long taskId;

    /**
     * 用户id
     */
    @ApiModelProperty(value = "用户id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long userId;

    /**
     * 仓位id
     */
    @ApiModelProperty(value = "仓位id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long positionId;

    /**
     * 订单id
     */
    @ApiModelProperty(value = "订单id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long orderId;

    /**
     * 币对名称
     */
    @ApiModelProperty(value = "币对名称")
    private String symbolName;

    /**
     * 产品名称
     */
    @ApiModelProperty(value = "产品名称")
    private String productName;

    /**
     * 方向（0做多、1做空）
     */
    @ApiModelProperty(value = "方向（0做多、1做空）")
    private String side;

    /**
     * 数量类型（0张数、1百分比）
     */
    @ApiModelProperty(value = "数量类型（0张数、1百分比）")
    private String numType;

    /**
     * 委托数量
     */
    @ApiModelProperty(value = "委托数量")
    private Integer num;

    /**
     * 委托百分比数量（只支持100%）
     */
    @ApiModelProperty(value = "委托百分比数量（只支持100%）")
    @JsonSerialize(using = BigDecimalToPlainStringSerializer.class)
    private BigDecimal numPercent;

    /**
     * 单向/双向（0单向、1双向）
     */
    @ApiModelProperty(value = "单向/双向（0单向、1双向）")
    private String sideType;

    /**
     * 是否止盈（0否、1是）
     */
    @ApiModelProperty(value = "是否止盈（0否、1是）")
    private String hasStopProfit;

    /**
     * 止盈触发价格，是否止盈为是时不能为空
     */
    @ApiModelProperty(value = "止盈触发价格，是否止盈为是时不能为空")
    @JsonSerialize(using = BigDecimalToPlainStringSerializer.class)
    private BigDecimal stopProfitTrigger;

    /**
     * 止盈价格类型（0市价、1限价），是否止盈为是时不能为空
     */
    @ApiModelProperty(value = "止盈价格类型（0市价、1限价），是否止盈为是时不能为空")
    private String stopProfitType;

    /**
     * 止盈价格，止盈价格类型为限价时不能为空
     */
    @ApiModelProperty(value = "止盈价格，止盈价格类型为限价时不能为空")
    @JsonSerialize(using = BigDecimalToPlainStringSerializer.class)
    private BigDecimal stopProfitPrice;

    /**
     * 止盈价格类型（0最新价格、1指数价格、2标记价格）
     */
    @ApiModelProperty(value = "止盈价格类型（0最新价格、1指数价格、2标记价格）")
    private String stopProfitPriceType;

    /**
     * 是否止损（0否、1是）
     */
    @ApiModelProperty(value = "是否止损（0否、1是）")
    private String hasStopLost;

    /**
     * 止损触发价格，是否止损为是时不能为空
     */
    @ApiModelProperty(value = "止损触发价格，是否止损为是时不能为空")
    @JsonSerialize(using = BigDecimalToPlainStringSerializer.class)
    private BigDecimal stopLostTrigger;

    /**
     * 止损价格类型（0市价、1限价），是否止损为是时不能为空
     */
    @ApiModelProperty(value = "止损价格类型（0市价、1限价），是否止损为是时不能为空")
    private String stopLostType;

    /**
     * 止损价格，止损价格类型为限价时不能为空
     */
    @ApiModelProperty(value = "止损价格，止损价格类型为限价时不能为空")
    @JsonSerialize(using = BigDecimalToPlainStringSerializer.class)
    private BigDecimal stopLostPrice;

    /**
     * 止损价格类型（0最新价格、1指数价格、2标记价格）
     */
    @ApiModelProperty(value = "止损价格类型（0最新价格、1指数价格、2标记价格）")
    private String stopLostPriceType;

    /**
     * 实际触发方向（0止盈、1止损
     */
    @ApiModelProperty(value = "实际触发方向（0止盈、1止损）")
    private String actualTriggerSide;

    /**
     * 触发时间
     */
    @ApiModelProperty(value = "触发时间")
    private LocalDateTime triggerTime;

    /**
     * 实际委托数量
     */
    @ApiModelProperty(value = "实际委托数量")
    private Integer actualNum;

    /**
     * 实际委托金额
     */
    @ApiModelProperty(value = "实际委托金额")
    @JsonSerialize(using = BigDecimalToPlainStringSerializer.class)
    private BigDecimal actualPrice;

    /**
     * 同步次数
     */
    @ApiModelProperty(value = "同步次数")
    private Integer syncCount;

    /**
     * 同步状态（0未同步、1同步中、2同步成功）
     */
    @ApiModelProperty(value = "同步状态（0未同步、1同步中、2同步成功）")
    private String syncStatus;

    /**
     * 标签
     */
    @ApiModelProperty(value = "标签")
    private String tag;

    /**
     * 备注
     */
    @ApiModelProperty(value = "备注")
    private String remark;

    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createTime;

    /**
     * 创建人
     */
    @ApiModelProperty(value = "创建人")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long createBy;

    /**
     * 修改时间
     */
    @ApiModelProperty(value = "修改时间")
    private LocalDateTime updateTime;

    /**
     * 修改人
     */
    @ApiModelProperty(value = "修改人")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long updateBy;

    /**
     * 委托状态（0待生效、1已生效、2已撤销、3委托失败、4异常）
     */
    @ApiModelProperty(value = "委托状态（0待生效、1已生效、2已撤销、3委托失败、4异常）")
    private String status;

    /**
     * 是否删除（null是、0否）
     */
    @TableLogic
    private String isDeleted;
}
